import {
    increment,
    decrement,
    addValue,
    syncAddvalue
} from "../store/counterSlice";
import { useSelector, useDispatch } from "react-redux";
import qs from "querystring";
import React from "react"; // 确保导入了 React  
import { useLocation } from "react-router-dom"; // 使用 useLocation Hook 获取 location  

export default function Login() {
    const dispatch = useDispatch();
    const count = useSelector(state => state.counter.value);
    const location = useLocation(); // 使用 useLocation Hook 代替 this.props.location  
    const search = location.search;
    const { id, title } = qs.parse(search.slice(1));

    console.log(id, title);

    return (
        <div>
            <p>仓库数据：{count}</p>
            <button onClick={() => dispatch(increment())}>+1</button>
            <button onClick={() => dispatch(decrement())}>-1</button>
            <button onClick={() => dispatch(addValue(5))}>+5</button>
            <button onClick={() => dispatch(syncAddvalue(10))}>两秒后+10</button>
        </div>
    );
};